package com.lagou.edu.controller;

import com.lagou.edu.pojo.CommonResult;
import com.lagou.edu.pojo.Resume;
import com.lagou.edu.service.impl.ResumeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @author yangpeng
 * @time 2020/3/14
 * @since 1.0.0
 */
@RequestMapping("/resume")
@Controller
public class ResumeController {

    @Autowired
    ResumeService resumeService;

    @RequestMapping("/index")
    public String index(){
        return "resume";
    }

    @RequestMapping("/add")
    @ResponseBody
    public CommonResult addResume(Resume resume){
        boolean flag = resumeService.addResume(resume);
        if(flag){
            return new CommonResult(1,"成功");
        }else{
            return new CommonResult(2,"新增失败");
        }
    }

    @RequestMapping("/update")
    @ResponseBody
    public CommonResult updateResume(Resume resume){
        boolean flag = resumeService.updateResume(resume);
        if(flag){
            return new CommonResult(1,"成功");
        }else{
            return new CommonResult(2,"修改失败");
        }
    }

    @RequestMapping("/delete")
    @ResponseBody
    public CommonResult deleteResume(Long id){
        boolean flag = resumeService.deleteResume(id);
        if(flag){
            return new CommonResult(1,"成功");
        }else{
            return new CommonResult(2,"删除失败");
        }
    }

    @RequestMapping("/list")
    @ResponseBody
    public CommonResult queryAllList(){
        List<Resume> list = resumeService.queryAllList();
        return new CommonResult(1,"成功",list);
    }
}
